package com.sxjh.controller.financialrepost;

import com.sxjh.common.Result;
import com.sxjh.entity.param.BalanceRepostParam;
import com.sxjh.entity.param.FinancialSalesRepostParam;
import com.sxjh.entity.result.BalanceRepostResult;
import com.sxjh.entity.result.FinanceHgylCgResult;
import com.sxjh.entity.result.FinancialRepostResult;
import com.sxjh.entity.result.SalesReport;
import com.sxjh.service.financialrepost.FinancialRepostService;
import com.sxjh.uitl.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zxz
 * @Date 2021/11/19
 * @Description: 财务采购对账报表控制层
 */
@RestController
@RequestMapping("/financial/stock/report")
@Api(tags = "财务采购对账报表")
public class FinancialStockRepostController {
    @Autowired
    private FinancialRepostService financialRepostService;

    /*化工原料采购报表*/
    @ApiOperation("化工原料采购报表")
    @GetMapping("/hgyl/cg/bb")
//  @Authorization("cb.finance.list")
    Result<PageUtil<FinanceHgylCgResult>> hgylCgBb(@Validated FinancialSalesRepostParam param) {
//        if (param.getMaterialId() == 85) {
            return Result.ok(financialRepostService.getChemicalRawMaterialPurchaseReport(param));
//        } else {
//            return Result.ok(financialRepostService.getChemicalRawMaterialPurchaseReport(param));
//        }
    }

    /*余额报表*/
    @ApiOperation("余额报表")
    @GetMapping("/balance/report")
//  @Authorization("cb.finance.list")
    Result<List<BalanceRepostResult>> hgylCgBb(@Validated BalanceRepostParam param) {
        return Result.ok(financialRepostService.getMonthBalance(param));
    }

    /*余额报表*/
    @ApiOperation("保存余额")
    @PostMapping("/savaBalance")
    Result<Map<String,Object>> savaBalance (@Validated BalanceRepostParam param) {
        return Result.ok(financialRepostService.savaBalance(param));
    }

    /*销售报表*/
    @ApiOperation("销售报表")
    @GetMapping("/sales/report")
//  @Authorization("cb.finance.list")
    Result<List<SalesReport>> getSalesRepost(@Validated FinancialSalesRepostParam param) {
        return Result.ok(financialRepostService.getSalesRepost(param));
    }
    /*销售报表*/
    @ApiOperation("销售明细报表")
    @GetMapping("/sales/mx/report")
//  @Authorization("cb.finance.list")
    Result<List<SalesReport>> getSalesMxRepost(@Validated FinancialSalesRepostParam param) {
        return Result.ok(financialRepostService.getSalesMxRepost(param));
    }
}
